//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2024 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto-codegenerator.
// DO NOT EDIT.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
@_exported import SotoCore

/// Service object for interacting with AWS KeyspacesStreams service.
///
/// Amazon Keyspaces (for Apache Cassandra) change data capture (CDC) records change events for Amazon Keyspaces tables. The change events captured in a stream are time-ordered and de-duplicated write operations. Using stream data you can build event driven applications that incorporate near-real time change events from Amazon Keyspaces tables.  Amazon Keyspaces CDC is serverless and scales the infrastructure for change events automatically based on the volume of changes on your table.   This API reference describes the Amazon Keyspaces CDC stream API in detail.  For more information about Amazon Keyspaces CDC, see Working with change data capture (CDC) streams in Amazon Keyspaces in the Amazon Keyspaces Developer Guide. To learn how Amazon Keyspaces CDC API actions are recorded with CloudTrail, see Amazon Keyspaces information in CloudTrail in the Amazon Keyspaces Developer Guide. To see the metrics Amazon Keyspaces CDC sends to Amazon CloudWatch, see Amazon Keyspaces change data capture (CDC) CloudWatch metrics in the Amazon Keyspaces Developer Guide.
public struct KeyspacesStreams: AWSService {
    // MARK: Member variables

    /// Client used for communication with AWS
    public let client: AWSClient
    /// Service configuration
    public let config: AWSServiceConfig

    // MARK: Initialization

    /// Initialize the KeyspacesStreams client
    /// - parameters:
    ///     - client: AWSClient used to process requests
    ///     - region: Region of server you want to communicate with. This will override the partition parameter.
    ///     - partition: AWS partition where service resides, standard (.aws), china (.awscn), government (.awsusgov).
    ///     - endpoint: Custom endpoint URL to use instead of standard AWS servers
    ///     - middleware: Middleware chain used to edit requests before they are sent and responses before they are decoded 
    ///     - timeout: Timeout value for HTTP requests
    ///     - byteBufferAllocator: Allocator for ByteBuffers
    ///     - options: Service options
    public init(
        client: AWSClient,
        region: SotoCore.Region? = nil,
        partition: AWSPartition = .aws,
        endpoint: String? = nil,
        middleware: AWSMiddlewareProtocol? = nil,
        timeout: TimeAmount? = nil,
        byteBufferAllocator: ByteBufferAllocator = ByteBufferAllocator(),
        options: AWSServiceConfig.Options = []
    ) {
        self.client = client
        self.config = AWSServiceConfig(
            region: region,
            partition: region?.partition ?? partition,
            amzTarget: "KeyspacesStreams",
            serviceName: "KeyspacesStreams",
            serviceIdentifier: "cassandra-streams",
            signingName: "cassandra",
            serviceProtocol: .json(version: "1.0"),
            apiVersion: "2024-09-09",
            endpoint: endpoint,
            errorType: KeyspacesStreamsErrorType.self,
            middleware: middleware,
            timeout: timeout,
            byteBufferAllocator: byteBufferAllocator,
            options: options
        )
    }





    // MARK: API Calls

    /// Retrieves data records from a specified shard in an Amazon Keyspaces data stream. This operation returns a collection of data records from the shard, including the primary key columns and information about modifications made to the captured table data. Each record represents a single data modification in the Amazon Keyspaces table and includes metadata about when the change occurred.
    @Sendable
    @inlinable
    public func getRecords(_ input: GetRecordsInput, logger: Logger = AWSClient.loggingDisabled) async throws -> GetRecordsOutput {
        try await self.client.execute(
            operation: "GetRecords", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Retrieves data records from a specified shard in an Amazon Keyspaces data stream. This operation returns a collection of data records from the shard, including the primary key columns and information about modifications made to the captured table data. Each record represents a single data modification in the Amazon Keyspaces table and includes metadata about when the change occurred.
    ///
    /// Parameters:
    ///   - maxResults:  The maximum number of records to return in a single GetRecords request. Default value is 1000. You can specify a limit between 1 and 1000, but the actual number returned might be less than the specified maximum if the size of the data for the returned records exceeds the internal size limit.
    ///   - shardIterator:  The unique identifier of the shard iterator. A shard iterator specifies the position in the shard from which you want to start reading data records sequentially. You obtain this value by calling the GetShardIterator operation. Each shard iterator is valid for 15 minutes after creation.
    ///   - logger: Logger use during operation
    @inlinable
    public func getRecords(
        maxResults: Int? = nil,
        shardIterator: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetRecordsOutput {
        let input = GetRecordsInput(
            maxResults: maxResults, 
            shardIterator: shardIterator
        )
        return try await self.getRecords(input, logger: logger)
    }

    /// Returns a shard iterator that serves as a bookmark for reading data from a specific position in an Amazon Keyspaces data stream's shard. The shard iterator specifies the shard position from which to start reading data records sequentially. You can specify whether to begin reading at the latest record, the oldest record, or at a particular sequence number within the shard.
    @Sendable
    @inlinable
    public func getShardIterator(_ input: GetShardIteratorInput, logger: Logger = AWSClient.loggingDisabled) async throws -> GetShardIteratorOutput {
        try await self.client.execute(
            operation: "GetShardIterator", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns a shard iterator that serves as a bookmark for reading data from a specific position in an Amazon Keyspaces data stream's shard. The shard iterator specifies the shard position from which to start reading data records sequentially. You can specify whether to begin reading at the latest record, the oldest record, or at a particular sequence number within the shard.
    ///
    /// Parameters:
    ///   - sequenceNumber:  The sequence number of the data record in the shard from which to start reading. Required if ShardIteratorType is AT_SEQUENCE_NUMBER or AFTER_SEQUENCE_NUMBER. This parameter is ignored for other iterator types.
    ///   - shardId:  The identifier of the shard within the stream. The shard ID uniquely identifies a subset of the stream's data records that you want to access.
    ///   - shardIteratorType:  Determines how the shard iterator is positioned. Must be one of the following:    TRIM_HORIZON - Start reading at the last untrimmed record in the shard, which is the oldest data record in the shard.    AT_SEQUENCE_NUMBER - Start reading exactly from the specified sequence number.    AFTER_SEQUENCE_NUMBER - Start reading right after the specified sequence number.    LATEST - Start reading just after the most recent record in the shard, so that you always read the most recent data.
    ///   - streamArn:  The Amazon Resource Name (ARN) of the stream for which to get the shard iterator. The ARN uniquely identifies the stream within Amazon Keyspaces.
    ///   - logger: Logger use during operation
    @inlinable
    public func getShardIterator(
        sequenceNumber: String? = nil,
        shardId: String,
        shardIteratorType: ShardIteratorType,
        streamArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetShardIteratorOutput {
        let input = GetShardIteratorInput(
            sequenceNumber: sequenceNumber, 
            shardId: shardId, 
            shardIteratorType: shardIteratorType, 
            streamArn: streamArn
        )
        return try await self.getShardIterator(input, logger: logger)
    }

    /// Returns detailed information about a specific data capture stream for an Amazon Keyspaces table. The information includes the stream's Amazon Resource Name (ARN), creation time, current status, retention period, shard composition, and associated table details. This operation helps you monitor and manage the configuration of your Amazon Keyspaces data streams.
    @Sendable
    @inlinable
    public func getStream(_ input: GetStreamInput, logger: Logger = AWSClient.loggingDisabled) async throws -> GetStreamOutput {
        try await self.client.execute(
            operation: "GetStream", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns detailed information about a specific data capture stream for an Amazon Keyspaces table. The information includes the stream's Amazon Resource Name (ARN), creation time, current status, retention period, shard composition, and associated table details. This operation helps you monitor and manage the configuration of your Amazon Keyspaces data streams.
    ///
    /// Parameters:
    ///   - maxResults:  The maximum number of shard objects to return in a single GetStream request. Default value is 100. The minimum value is 1 and the maximum value is 100.
    ///   - nextToken:  An optional pagination token provided by a previous GetStream operation. If this parameter is specified, the response includes only records beyond the token, up to the value specified by maxResults.
    ///   - shardFilter:  Optional filter criteria to apply when retrieving shards. You can filter shards based on their state or other attributes to narrow down the results returned by the GetStream operation.
    ///   - streamArn:  The Amazon Resource Name (ARN) of the stream for which detailed information is requested. This uniquely identifies the specific stream you want to get information about.
    ///   - logger: Logger use during operation
    @inlinable
    public func getStream(
        maxResults: Int? = nil,
        nextToken: String? = nil,
        shardFilter: ShardFilter? = nil,
        streamArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> GetStreamOutput {
        let input = GetStreamInput(
            maxResults: maxResults, 
            nextToken: nextToken, 
            shardFilter: shardFilter, 
            streamArn: streamArn
        )
        return try await self.getStream(input, logger: logger)
    }

    /// Returns a list of all data capture streams associated with your Amazon Keyspaces account or for a specific keyspace or table. The response includes information such as stream ARNs, table associations, creation timestamps, and current status. This operation helps you discover and manage all active data streams in your Amazon Keyspaces environment.
    @Sendable
    @inlinable
    public func listStreams(_ input: ListStreamsInput, logger: Logger = AWSClient.loggingDisabled) async throws -> ListStreamsOutput {
        try await self.client.execute(
            operation: "ListStreams", 
            path: "/", 
            httpMethod: .POST, 
            serviceConfig: self.config, 
            input: input, 
            logger: logger
        )
    }
    /// Returns a list of all data capture streams associated with your Amazon Keyspaces account or for a specific keyspace or table. The response includes information such as stream ARNs, table associations, creation timestamps, and current status. This operation helps you discover and manage all active data streams in your Amazon Keyspaces environment.
    ///
    /// Parameters:
    ///   - keyspaceName:  The name of the keyspace for which to list streams. If specified, only streams associated with tables in this keyspace are returned. If omitted, streams from all keyspaces are included in the results.
    ///   - maxResults:  The maximum number of streams to return in a single ListStreams request. Default value is 100. The minimum value is 1 and the maximum value is 100.
    ///   - nextToken:  An optional pagination token provided by a previous ListStreams operation. If this parameter is specified, the response includes only records beyond the token, up to the value specified by maxResults.
    ///   - tableName:  The name of the table for which to list streams. Must be used together with keyspaceName. If specified, only streams associated with this specific table are returned.
    ///   - logger: Logger use during operation
    @inlinable
    public func listStreams(
        keyspaceName: String? = nil,
        maxResults: Int? = nil,
        nextToken: String? = nil,
        tableName: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) async throws -> ListStreamsOutput {
        let input = ListStreamsInput(
            keyspaceName: keyspaceName, 
            maxResults: maxResults, 
            nextToken: nextToken, 
            tableName: tableName
        )
        return try await self.listStreams(input, logger: logger)
    }
}

extension KeyspacesStreams {
    /// Initializer required by `AWSService.with(middlewares:timeout:byteBufferAllocator:options)`. You are not able to use this initializer directly as there are not public
    /// initializers for `AWSServiceConfig.Patch`. Please use `AWSService.with(middlewares:timeout:byteBufferAllocator:options)` instead.
    public init(from: KeyspacesStreams, patch: AWSServiceConfig.Patch) {
        self.client = from.client
        self.config = from.config.with(patch: patch)
    }
}

// MARK: Paginators

@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
extension KeyspacesStreams {
    /// Return PaginatorSequence for operation ``getStream(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func getStreamPaginator(
        _ input: GetStreamInput,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<GetStreamInput, GetStreamOutput> {
        return .init(
            input: input,
            command: self.getStream,
            inputKey: \GetStreamInput.nextToken,
            outputKey: \GetStreamOutput.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``getStream(_:logger:)``.
    ///
    /// - Parameters:
    ///   - maxResults:  The maximum number of shard objects to return in a single GetStream request. Default value is 100. The minimum value is 1 and the maximum value is 100.
    ///   - shardFilter:  Optional filter criteria to apply when retrieving shards. You can filter shards based on their state or other attributes to narrow down the results returned by the GetStream operation.
    ///   - streamArn:  The Amazon Resource Name (ARN) of the stream for which detailed information is requested. This uniquely identifies the specific stream you want to get information about.
    ///   - logger: Logger used for logging
    @inlinable
    public func getStreamPaginator(
        maxResults: Int? = nil,
        shardFilter: ShardFilter? = nil,
        streamArn: String,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<GetStreamInput, GetStreamOutput> {
        let input = GetStreamInput(
            maxResults: maxResults, 
            shardFilter: shardFilter, 
            streamArn: streamArn
        )
        return self.getStreamPaginator(input, logger: logger)
    }

    /// Return PaginatorSequence for operation ``listStreams(_:logger:)``.
    ///
    /// - Parameters:
    ///   - input: Input for operation
    ///   - logger: Logger used for logging
    @inlinable
    public func listStreamsPaginator(
        _ input: ListStreamsInput,
        logger: Logger = AWSClient.loggingDisabled
    ) -> AWSClient.PaginatorSequence<ListStreamsInput, ListStreamsOutput> {
        return .init(
            input: input,
            command: self.listStreams,
            inputKey: \ListStreamsInput.nextToken,
            outputKey: \ListStreamsOutput.nextToken,
            logger: logger
        )
    }
    /// Return PaginatorSequence for operation ``listStreams(_:logger:)``.
    ///
    /// - Parameters:
    ///   - keyspaceName:  The name of the keyspace for which to list streams. If specified, only streams associated with tables in this keyspace are returned. If omitted, streams from all keyspaces are included in the results.
    ///   - maxResults:  The maximum number of streams to return in a single ListStreams request. Default value is 100. The minimum value is 1 and the maximum value is 100.
    ///   - tableName:  The name of the table for which to list streams. Must be used together with keyspaceName. If specified, only streams associated with this specific table are returned.
    ///   - logger: Logger used for logging
    @inlinable
    public func listStreamsPaginator(
        keyspaceName: String? = nil,
        maxResults: Int? = nil,
        tableName: String? = nil,
        logger: Logger = AWSClient.loggingDisabled        
    ) -> AWSClient.PaginatorSequence<ListStreamsInput, ListStreamsOutput> {
        let input = ListStreamsInput(
            keyspaceName: keyspaceName, 
            maxResults: maxResults, 
            tableName: tableName
        )
        return self.listStreamsPaginator(input, logger: logger)
    }
}

extension KeyspacesStreams.GetStreamInput: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> KeyspacesStreams.GetStreamInput {
        return .init(
            maxResults: self.maxResults,
            nextToken: token,
            shardFilter: self.shardFilter,
            streamArn: self.streamArn
        )
    }
}

extension KeyspacesStreams.ListStreamsInput: AWSPaginateToken {
    @inlinable
    public func usingPaginationToken(_ token: String) -> KeyspacesStreams.ListStreamsInput {
        return .init(
            keyspaceName: self.keyspaceName,
            maxResults: self.maxResults,
            nextToken: token,
            tableName: self.tableName
        )
    }
}
